{extend name="public/nav"}

{block name="css"}
<style type="text/css">
.img{
  width: 168px;
  height: 168px;
  background-position: center center;
  background-size: cover;
  display: inline-block;
}
</style>

{/block}

{block name='main'}
<!-- content start -->
  <div class="admin-content">

    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">{$album['aname']}</strong> / <small>Gallery</small></div>
    </div>
    <div class="am-g">
      <div class="am-u-md-6 am-cf">
        <div class="am-fl am-cf">
          <div class="am-btn-toolbar am-fl">
              <div class="am-btn-group am-btn-group-xs">
                <button type="button" class="am-btn am-btn-default" onclick='btu_create()'><span class="am-icon-plus"></span> 上传图片</button>

            </div>
          </div>
        </div>
      </div>
    </div>

    <ul class="am-avg-sm-2 am-avg-md-4 am-avg-lg-6 am-margin gallery-list" id="picture">
      {foreach $list as $v}
      <li>
        <a href="#" onclick="showPicture()">
          <img class="am-img-thumbnail am-img-bdrs img" layer-src="{$v.path}" src="{$v.path}" alt="{$v.pname}"/>
        </a>
          <div class="gallery-title">{$v.pname}</div>

        <div>

        </div>
        <div class="gallery-desc">{:date('Y-m-d')} <a href="#" onclick="layer.alert('{$v.path}')">外链</a> <a href="#" onclick="setUpdate({$v['id']})">修改</a> <a href="#" onclick="onDelete({$v.id})">删除</a></div>

      </li>
      {/foreach}
      {if(!$list)}
      <li id="kong">
        <span>该相册空空如也， 你可以<a href="#" onclick="btu_create()">上传图片</a></span>
      </li>

      {/if}
    </ul>



    <div class="am-margin am-cf">
      {$page}
    </div>

  </div>
{/block}

{block name="js"}
<script type="text/javascript">
  function btu_create(){
    layer.open({
          type: 2,
          title:'图片上传',
          area: ['900px', '530px'],
          fix: false, //不固定
          maxmin: true,
          content: "{:U('picture/create',['aid'=>$album['id']])}"
      });
      }

    function setUpdate(pid){
        layer.open({
            type: 2,
            title:'图片修改',
            area: ['700px', '530px'],
            fix: false, //不固定
            maxmin: true,
            content: "{:U('picture/update')}"+"?pid="+pid
        });
    }

    function onDelete(id){
        layer.confirm('是否删除该图片？', {
            btn: ['删除','取消'], //按钮
            icon: 0
        }, function(){
            layer.msg('正在删除中，请稍候。。。', {time: 500},function(){
                $.post("{:U('picture/delete')}",{pid:id},function(){
                    location.reload();
                });
            });
        });
    }

  layer.config({
      extend: 'extend/layer.ext.js'
  });


  function showPicture(){
    layer.photos({
        photos: '#picture'
    });
  }
</script>
{/block}
